home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / Macintosh Sample Code / SC.016.OffSample / OffSample.r < prev    next >
Encoding:
Text File  |  1989-03-31  |  7.2 KB  |  346 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    Offscreen Buffer Sample Application
  6. #
  7. #    OffSample
  8. #
  9. #    OffSample.r        -    Rez Source
  10. #
  11. #    Copyright © 1989 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    
  15. #                1.00                04/89
  16. #
  17. #    Components:
  18. #                OffSample.p            April 1, 1989
  19. #                OffSample.r            April 1, 1989
  20. #                OffSample.h            April 1, 1989
  21. #                POffSample.make        April 1, 1989
  22. #
  23. #    Requirements:
  24. #                Offscreen.p            April 1, 1989
  25. #                Offscreen.inc1.p    April 1, 1989
  26. #                UFailure.p            November 1, 1988
  27. #                UFailure.inc1.p        November 1, 1988
  28. #                UFailure.a            November 1, 1988
  29. #
  30. #    OffSample demonstrates the usage of the Offscreen
  31. #    unit. It shows how to use offscreen pixmaps and
  32. #    bitmaps to produce flicker-free updating with a
  33. #    minimum of re-structuring of code. OffSample attempts
  34. #    to reduce the amount of 'knowledge' that it has of
  35. #    the offscreen structure so as to minimize its
  36. #    dependence on that unit.
  37. #
  38. #    OffSample emphasizes using the Offscreen unit; it
  39. #    is not intended to be viewed as a complete application
  40. #    from which to base some larger effort. Instead, its
  41. #    method of using offscreen bitmaps and pixmaps should
  42. #    be studied and adapted to other applications that
  43. #    desire features such as flicker-free updating.
  44. #
  45. ------------------------------------------------------------------------------*/
  46.  
  47.  
  48. #include "Types.r"
  49.  
  50. #include "OffSample.h"
  51.  
  52. include "OffSample.rsrc";
  53.  
  54. /* we use an MBAR resource to conveniently load all the menus */
  55.  
  56. resource 'MBAR' (rMenuBar, preload) {
  57.     { mApple, mFile, mEdit, mShape, mSpecial };    /* five menus */
  58. };
  59.  
  60.  
  61. resource 'MENU' (mApple, preload) {
  62.     mApple, textMenuProc,
  63.     AllItems & ~MenuItem2,    /* Disable dashed line, enable About and DAs */
  64.     enabled, apple,
  65.     {
  66.         "About OffSample…",
  67.             noicon, nokey, nomark, plain;
  68.         "-",
  69.             noicon, nokey, nomark, plain
  70.     }
  71. };
  72.  
  73. resource 'MENU' (mFile, preload) {
  74.     mFile, textMenuProc,
  75.     MenuItem1 | MenuItem12,                /* enable New and Quit only, program enables others */
  76.     enabled, "File",
  77.     {
  78.         "New",
  79.             noicon, "N", nomark, plain;
  80.         "Open",
  81.             noicon, "O", nomark, plain;
  82.         "-",
  83.             noicon, nokey, nomark, plain;
  84.         "Close",
  85.             noicon, "W", nomark, plain;
  86.         "Save",
  87.             noicon, "S", nomark, plain;
  88.         "Save As…",
  89.             noicon, nokey, nomark, plain;
  90.         "Revert",
  91.             noicon, nokey, nomark, plain;
  92.         "-",
  93.             noicon, nokey, nomark, plain;
  94.         "Page Setup…",
  95.             noicon, nokey, nomark, plain;
  96.         "Print…",
  97.             noicon, nokey, nomark, plain;
  98.         "-",
  99.             noicon, nokey, nomark, plain;
  100.         "Quit",
  101.             noicon, "Q", nomark, plain
  102.     }
  103. };
  104.  
  105. resource 'MENU' (mEdit, preload) {
  106.     mEdit, textMenuProc,
  107.     NoItems,                /* disable everything, program does the enabling */
  108.     enabled, "Edit",
  109.      {
  110.         "Undo",
  111.             noicon, "Z", nomark, plain;
  112.         "-",
  113.             noicon, nokey, nomark, plain;
  114.         "Cut",
  115.             noicon, "X", nomark, plain;
  116.         "Copy",
  117.             noicon, "C", nomark, plain;
  118.         "Paste",
  119.             noicon, "V", nomark, plain;
  120.         "Clear",
  121.             noicon, nokey, nomark, plain
  122.     }
  123. };
  124.  
  125. resource 'MENU' (mShape, preload) {
  126.     mShape, textMenuProc,
  127.     AllItems,                /* Enable all */
  128.     enabled, "Shapes",
  129.     {
  130.         "Oval",
  131.             noicon, nokey, check, plain;
  132.         "Region",
  133.             noicon, nokey, nomark, plain;
  134.         "RoundRect",
  135.             noicon, nokey, nomark, plain;
  136.         "Polygon",
  137.             noicon, nokey, nomark, plain;
  138.         "Rect",
  139.             noicon, nokey, nomark, plain;
  140.         "Moof!™",
  141.             noicon, nokey, nomark, plain;
  142.         "Gigantor",
  143.             noicon, nokey, nomark, plain
  144.     }
  145. };
  146.  
  147. resource 'MENU' (mSpecial, preload) {
  148.     mSpecial, textMenuProc,
  149.     AllItems & ~MenuItem3,    /* Disable dashed line */
  150.     enabled, "Special",
  151.     {
  152.         "Attempt Background Buffer",
  153.             noicon, nokey, check, plain;
  154.         "Attempt Foreground Buffer",
  155.             noicon, nokey, check, plain;
  156.         "-",
  157.             noicon, nokey, nomark, plain;
  158.         "Pick Object Color…",
  159.             noicon, nokey, nomark, plain
  160.     }
  161. };
  162.  
  163.  
  164. /* this ALRT and DITL are used as an About screen */
  165.  
  166. resource 'ALRT' (rAboutAlert, purgeable) {
  167.     {40, 20, 160, 290},
  168.     rAboutAlert,
  169.     { /* array: 4 elements */
  170.         /* [1] */
  171.         OK, visible, silent,
  172.         /* [2] */
  173.         OK, visible, silent,
  174.         /* [3] */
  175.         OK, visible, silent,
  176.         /* [4] */
  177.         OK, visible, silent
  178.     }
  179. };
  180.  
  181. resource 'DITL' (rAboutAlert, purgeable) {
  182.     { /* array DITLarray: 5 elements */
  183.         /* [1] */
  184.         {88, 180, 108, 260},
  185.         Button {
  186.             enabled,
  187.             "OK"
  188.         },
  189.         /* [2] */
  190.         {8, 8, 24, 214},
  191.         StaticText {
  192.             disabled,
  193.             "Offscreen Sample"
  194.         },
  195.         /* [3] */
  196.         {32, 8, 48, 237},
  197.         StaticText {
  198.             disabled,
  199.             "Copyright © 1989 Apple Computer"
  200.         },
  201.         /* [4] */
  202.         {56, 8, 72, 136},
  203.         StaticText {
  204.             disabled,
  205.             "Brought to you by:"
  206.         },
  207.         /* [5] */
  208.         {80, 24, 112, 167},
  209.         StaticText {
  210.             disabled,
  211.             "Macintosh Developer  Technical Support"
  212.         }
  213.     }
  214. };
  215.  
  216.  
  217. /* this ALRT and DITL are used as an error screen */
  218.  
  219. resource 'ALRT' (rUserAlert, purgeable) {
  220.     {40, 20, 180, 260},
  221.     rUserAlert,
  222.     { /* array: 4 elements */
  223.         /* [1] */
  224.         OK, visible, silent,
  225.         /* [2] */
  226.         OK, visible, silent,
  227.         /* [3] */
  228.         OK, visible, silent,
  229.         /* [4] */
  230.         OK, visible, silent
  231.     }
  232. };
  233.  
  234.  
  235. resource 'DITL' (rUserAlert, purgeable) {
  236.     { /* array DITLarray: 4 elements */
  237.         /* [1] */
  238.         {110, 150, 130, 230},
  239.         Button {
  240.             enabled,
  241.             "OK"
  242.         },
  243.         /* [2] */
  244.         {10, 60, 60, 230},
  245.         StaticText {
  246.             disabled,
  247.             "OffSample error. ^0."
  248.         },
  249.         /* [3] */
  250.         {70, 60, 90, 230},
  251.         StaticText {
  252.             disabled,
  253.             "^1"
  254.         },
  255.         /* [4] */
  256.         {8, 8, 40, 40},
  257.         Icon {
  258.             disabled,
  259.             2
  260.         }
  261.     }
  262. };
  263.  
  264.  
  265. resource 'STR#' (sErrStrings, purgeable) {
  266.     {
  267.     "An error occurred. The error number is: ";
  268.     "You must run on 512Ke or later";
  269.     "Application Memory Size is too small";
  270.     "Not enough memory to run OffSample";
  271.     }
  272. };
  273.  
  274.  
  275. resource 'STR ' (kNoBackBuff, purgeable) {
  276.     " / BackDealloc"
  277. };
  278.  
  279. resource 'STR ' (kNoEditBuff, purgeable) {
  280.     " / EditDeAlloc"
  281. };
  282.  
  283. resource 'STR ' (kTitle, purgeable) {
  284.     "Offscreen"
  285. };
  286.  
  287. resource 'STR ' (kColorPrompt, purgeable) {
  288.     "Select shape color."
  289. };
  290.  
  291. resource 'STR ' (kNoWantBack, purgeable) {
  292.     " / BackDenied"
  293. };
  294.  
  295. resource 'STR ' (kNoWantEdit, purgeable) {
  296.     " / EditDenied"
  297. };
  298.  
  299.  
  300. resource 'WIND' (rWindow, preload, purgeable) {
  301.     {60, 40, 290, 360},
  302.     noGrowDocProc, visible, goAway, 0x0, " "
  303. };
  304.  
  305.  
  306. resource 'pltt' (rWindow) {
  307.     {
  308.         0x0, 0x0, 0x0, pmTolerant, 0x0000,                /* Black */
  309.         0xFFFF, 0xFFFF, 0xFFFF, pmTolerant, 0x0000,        /* White */
  310.         0xFFFF, 0x0, 0x0, pmTolerant, 0x0000,            /* Oval's starting color    */
  311.         0x0, 0x0, 0xFFFF, pmTolerant, 0x0000,            /* Rgn's    "        "        */
  312.         0x9999, 0x6666, 0x0, pmTolerant, 0x0000,        /* RRect's    "        "        */
  313.         0x6666, 0x0, 0x9999, pmTolerant, 0x0000,        /* Poly's    "        "        */
  314.         0xCCCC, 0xCCCC, 0xCCCC, pmTolerant, 0x0000,        /* Rect's    "        "        */
  315.     }
  316. };
  317.  
  318.  
  319. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  320.  
  321. resource 'SIZE' (-1) {
  322.     dontSaveScreen,
  323.     acceptSuspendResumeEvents,
  324.     enableOptionSwitch,
  325.     canBackground,                /* we can background; we don't currently, but our */
  326.                                 /* sleep value guarantees we don't hog the Mac while */
  327.                                 /* we are in the background */
  328.     multiFinderAware,            /* this says we do our own activate/deactivate; don't */
  329.                                 /* fake us out */
  330.     backgroundAndForeground,    /* this is definitely not a background-only */
  331.                                 /* application! */
  332.     dontGetFrontClicks,            /* change this is if you want "do first click" */
  333.                                 /* behavior like the Finder */
  334.     ignoreChildDiedEvents,
  335.     is32BitCompatible,
  336.     reserved,
  337.     reserved,
  338.     reserved,
  339.     reserved,
  340.     reserved,
  341.     reserved,
  342.     reserved,
  343.     kPrefSize * 1024,
  344.     kMinSize * 1024    
  345. };
  346.